package factory_pattern.calculator02;

import java.util.Scanner;

/**
 * @Author xiumu
 * @Date 2019/2/27 20:23
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("请输入第一个数字：");
        Scanner input = new Scanner(System.in);
        double firstNumber = input.nextDouble();
        System.out.println("请输入运算符：");
        String operator = input.next();
        char oper = operator.charAt(0);
        Calculator calculator = OperatorFactory.createOperator(oper);
        System.out.println("请输入第二个数字：");
        double secondNumber = input.nextDouble();
        input.close();
        calculator.setFirstNumber(firstNumber);
        calculator.setSecondNumber(secondNumber);
        String result = calculator.getResult();
        System.out.println(calculator.getResult());
    }
}
